-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.0] Changes WebApp to use Express under the hood #12442
Conversation
changes connect by express
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems very interesting.
I would like to see this PR against current devel/master just to make sure everything is still working as expected.
Later we could apply it on top of 3.0 as I think this would be the right place to merge it.
What do you think @Grubba27 ?
Sounds great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only concern about this change are the defaults of connect
and express
. For example, I think we definitely should opt out of X-Powered-By
:
app.disable('x-powered-by');
And there are other things like that, including ETags. It may affect the performance and probably security significantly.
Co-authored-by: Radosław Miernik <radekmie@gmail.com>
Can you enumerate a little bit more? I will make the adjustments with |
|
Replacing connect with something that has a router will be very nice. It seems one of the main reasons for doing this now is express handles promise rejections better. This is coming in express 5, which is still in beta. As far as I know, express 4 doesn't handle it any better than connect does. We already modify connect so it supports fibers. We could do the same thing with connect or express so it handles rejected promises. Since there are so many breaking changes in Meteor 3, I'm wondering if there is a way to switch to express in a way that doesn't add more. It is possible to use express as a middleware for connect. Instead of removing connect completely, we could keep it for now, and add |
IMHO this:
It would be the best, but at the same time, I think that if we have the chance to move into something that is more well-known, it would be good for MeteorJS adoption. Regarding the amount of changes that we will have on this 3.0, it seems overwhelming. At the same time, it would be hard to maintain both connect and express. Let's take this chance of having a breaking change and move a few pieces because if we cannot change now, when can we? |
@Grubba27 First of all, I think it has to be done for every |
With express without disabling etag and x-powered-by: With express disabling etag and x-powered-by cc: @radekmie |
@Grubba27, am I correct with the following migration paths:
Did I miss anything? |
Hey, @rj-david, I would say that it Is a good practice just take a look at express 4 migration just in case you use a very specific connect feature that was not ported to express, I will update the docs & PR description to reflect this |
# Conflicts: # docs/history.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work as always @Grubba27 🎉
Well #12410 happened much earlier than I expected. 😂 |
Sorry about the number of files and changes
This PR focuses on changing connect framework for the Express framework.
Why is this happening?
The way connect handles async handlers is kind of awkward because it was made at a different time than ours, while we were removing fibers we decided to do another upgrade in the MeteorJS core. Give a more modern-ish look for core functionality.
To make async code work properly you would need to do something like this in your codebase:
We could have a function like @radekmie has shown me:
and could be used like this to have the same functionality that we have in Express:
Now with the new API the code above can be replaced with the following:
Does not seems much, but this will help us a lot in the core, and the community in the long term, as we can benefit a lot more from having 100% compatibility with the express plugin ecosystem.
But express was built on top of connect why the change?
From express docs:
This is an overall improvement as we can do it all the same way as before but now our webapp package is a little bit more complete.
What changes for me?
WebApp.connectHandlers.use(middleware)
is nowWebApp.expressHandlers.use(middleware)
WebApp.rawConnectHandlers.use(middleware)
is nowWebApp.rawExpressHandlers.use(middleware)
WebApp.connectApp
is nowWebApp.expressApp
If you have an edge case that may break because of compatibility issues here is express 4 migration guide
Running against devel tests:
This closes #12447